package com.weixin.controller;

import java.util.List;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.weixin.dao.Admin;

public class AdminController extends Controller{
	public Admin dao = new Admin();
	public void login(){
		String admin = getPara("user");
		String pass = getPara("pass");
		
		Admin a = dao.findFirst("select * from admin where user = ? and pass = ?" , admin , pass);
		if(a == null ){
			renderJson("code","0");
			
		}else{
			render("/static/output.jsp");
		}
	}
	
	public void exel(){
		List<Record> re = Db.find("select COUNT(*) as '游戏总人数' from users u LEFT JOIN store s ON s.id = u.store_id ");
		List<Record> rec = Db.find("SELECT u.`name` AS '姓名',u.gamenum AS '游戏分数 ',"
				+ "u.date AS '玩游戏的时间',"
				+ "u.phone AS '电话号码',"
				+ "u.persent_id AS '是否获奖'"
				+ " FROM "
				+ " users u "
				+ "LEFT JOIN store s ON s.id = u.id");
//		List<Admin> admin = dao.find("select COUNT(*) as '游戏总人数' from users u LEFT JOIN store s ON s.id = u.store_id ");
//		List<Admin> as = dao.find("SELECT u.`name` AS '姓名',u.gamenum AS '游戏分数 ',"
//				+ "u.date AS '玩游戏的时间',"
//				+ "u.phone AS '电话号码',"
//				+ "u.persent_id AS '是否获奖'"
//				+ " FROM"
//				+ "users u "
//				+ "LEFT JOIN store s ON s.id = u.id");
		List<Record> a = Db.find("select num from admin");
		renderJson(re);
	}
}
